cast text as date - Mailing list pgsql-sql

From lynch@lscorp.com (Richard Lynch)
Subject cast text as date
Date
Msg-id v02140b24b1ab8fc52a9f@[207.152.64.133]
Whole thread Raw
Responses Re: [SQL] cast text as date  (Herouth Maoz <herouth@oumail.openu.ac.il>)
List pgsql-sql
I'm probably an idiot, but I can't find a way in the docs or archives to
cast from text to date.  The text field in question looks like a date, and
I know there's a function to parse it 'cuz if it were in a table to be
imported using \copy it would work, but what that function would be called,
I'm failing to guess...  Does that make sense?

Here's the mess I've created:

I've got two tables that I need to "merge".  Both have mostly the same
fields but t1 has type 'text' on fields that are really, really dates, and
t1 has more rows than t2.  So I'm using:

insert into t2 select blah, blah, cast (blah as date) from t1 where not
exists (select id from t2 where t2.id = t1.id);

Maybe I'm just going about this all wrong...

I've never created a function of my own, and maybe that's the way to go,
but I'm not sure where to start...
The strings in question actually only have a month/year (no date), if that
matters (they're expirations)...
The resulting date can just default to 1 for the date.

--
--
-- "TANSTAAFL" Rich lynch@lscorp.com



pgsql-sql by date:

Previous
From: David Hartwig
Date:
Subject: Re: [SQL] Binary large objects
Next
From: "Francois TETE"
Date:
Subject: Rule "Delete"